const { PythonShell } = require('python-shell');
const path = require("path");

let options = {
    pythonPath:  'C:/PX4PSP/Python38/python.exe' // 指定Python解释器路径
};

const exeFilePath = process.platform === 'win32' ? process.execPath : '';
const exeDir = path.dirname(exeFilePath);

const scriptPath = process.env.NODE_ENV === 'development' ? path.resolve(__dirname, './') : `${exeDir}/resources/python`

const runPython = function () {
    PythonShell.run(scriptPath + 'TargetCreateDemo.py', options, (err, result) => {
        if (err) {
            console.error(err);
        }
        console.log('结果:', result);
    });
}

module.exports = {
    runPython,
}

